package com.ruoyi.demo.controller;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.demo.service.ITestDemoService;
import jodd.util.ThreadUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.lang.reflect.Array;
import java.nio.file.Watchable;
import java.util.Arrays;

/**
 * <简述>
 * <详细描述>
 *
 * @author syf
 * @date 2024年05月18日 15:52
 */
//@Component 交由spring管理
@Service
@Slf4j
public class AsyncService {

    @Autowired
    private ITestDemoService iTestDemoService;

    @Async
    @Transactional
    public void method1(){
        ThreadUtil.sleep(3000);
        iTestDemoService.deleteWithValidByIds(Arrays.asList(1L), false);
        log.info("method1----------->子线程");
        throw new ServiceException("异常");
    }
}
